package view.user;

import javax.swing.JPanel;
import javax.swing.JLabel;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import javax.swing.JRadioButton;
import javax.swing.JButton;
import javax.swing.ButtonGroup;
import controller.ActionEvents.ActionHandler;
import javax.swing.JComboBox;
import javax.swing.JTextField;

/**
 * Represents the Withdraw panel
 */
public class Withdrawal extends JPanel 
{
	
	/** ButtonGroup, which is a collection of radio buttons */
	private final ButtonGroup buttonGroup = new ButtonGroup();
	
	/** integer which represents the users choice	 */
	private int userChoice;

	private JLabel lblWithdrawal;
	private JComboBox comboBox;
	
	/** Declares objects of classes */
	private ActionHandler actionHandler;
	
	private JRadioButton rdbtnBike;
	private JRadioButton rdbtnProducts;
	private JRadioButton rdbtnAmbasssador;
	private JRadioButton rdbtnStairway;
	private JButton btnSubmit;
	private JLabel lblNewCategoryDefinition;
	private JTextField txtNewCategoryName;
	private JLabel lblAmount;
	private JTextField txtCategoryAmount;
	private JButton btnSubmitNewCategory;
	private JComboBox comboBoxUsersCategories;
	private JRadioButton rdbtnCustom;
	/**
	 * Create the withdrawal panel.
	 * It allow the user to withdraw an amount of CC.
	 */
	public Withdrawal(ActionHandler actionHandler) 
	{
		setLayout(null);
		setPreferredSize(new Dimension(750, 372));
		setBackground(Color.WHITE);
	
		this.actionHandler = actionHandler;
		
		lblWithdrawal = new JLabel("Withdrawal");
		lblWithdrawal.setFont(new Font("Euphemia UCAS", Font.PLAIN, 28));
		lblWithdrawal.setBounds(321, 6, 163, 39);
		add(lblWithdrawal);
		
		rdbtnBike = new JRadioButton("Took the bike to school");
		rdbtnBike.addActionListener(actionHandler);
		buttonGroup.add(rdbtnBike);
		rdbtnBike.setBounds(6, 118, 220, 32);
		add(rdbtnBike);
		
		rdbtnProducts = new JRadioButton("Bought green products");
		rdbtnProducts.addActionListener(actionHandler);
		rdbtnProducts.setBounds(6, 147, 188, 32);
		buttonGroup.add(rdbtnProducts);
		add(rdbtnProducts);
		
		rdbtnAmbasssador = new JRadioButton("Became green Ambassador");
		buttonGroup.add(rdbtnAmbasssador);
		rdbtnAmbasssador.setBounds(6, 176, 188, 32);
		rdbtnAmbasssador.addActionListener(actionHandler);
		add(rdbtnAmbasssador);
		
		
		btnSubmit = new JButton("");
		btnSubmit.addActionListener(actionHandler);
		btnSubmit.setActionCommand("withdrawalSUBMIT");
		btnSubmit.setBounds(46, 311, 89, 23);
		btnSubmit.setBorderPainted(false);
		btnSubmit.setContentAreaFilled(false);
		add(btnSubmit);
		
		rdbtnStairway = new JRadioButton("Took the stairway");
		buttonGroup.add(rdbtnStairway);
		rdbtnStairway.setBounds(6, 205, 208, 32);
		rdbtnStairway.addActionListener(actionHandler);
		rdbtnStairway.setActionCommand("STAIRWAY");
		add(rdbtnStairway);
		
	
		comboBox = new JComboBox();
		comboBox.setBounds(6, 269, 250, 23);
		add(comboBox);
		
		lblNewCategoryDefinition = new JLabel("New category definition");
		lblNewCategoryDefinition.setBounds(290, 127, 150, 16);
		add(lblNewCategoryDefinition);
		
		txtNewCategoryName = new JTextField();
		txtNewCategoryName.setBounds(452, 121, 246, 27);
		add(txtNewCategoryName);
		
		lblAmount = new JLabel("Amount");
		lblAmount.setBounds(511, 154, 61, 16);
		add(lblAmount);
		
		txtCategoryAmount = new JTextField();
		txtCategoryAmount.setColumns(10);
		txtCategoryAmount.setBounds(584, 148, 114, 27);
		add(txtCategoryAmount);
		
		btnSubmitNewCategory = new JButton("");
		btnSubmitNewCategory.setActionCommand("newWithdrawalCategorySubmit");
		btnSubmitNewCategory.addActionListener(actionHandler);
		btnSubmitNewCategory.setBounds(609, 187, 89, 23);
		btnSubmitNewCategory.setBorderPainted(false);
		btnSubmitNewCategory.setContentAreaFilled(false);
		add(btnSubmitNewCategory);
		
		comboBoxUsersCategories = new JComboBox();
		comboBoxUsersCategories.setBounds(40, 239, 216, 27);
		add(comboBoxUsersCategories);
		
		rdbtnCustom = new JRadioButton("");
		rdbtnCustom.setBounds(6, 239, 33, 23);
		buttonGroup.add(rdbtnCustom);
		add(rdbtnCustom);
	}
	
	/**
	 * @return the comboBoxUsersCategories
	 */
	public JComboBox getComboBoxUsersCategories() {
		return comboBoxUsersCategories;
	}

	/**
	 * @return the btnSubmit
	 */
	public JButton getBtnSubmit() {
		return btnSubmit;
	}

	/**
	 * @return the rdbtnBike
	 */
	public JRadioButton getRdbtnBike() {
		return rdbtnBike;
	}
	/**
	 * @param rdbtnBike the rdbtnBike to set
	 */
	public void setRdbtnBike(JRadioButton rdbtnBike) {
		this.rdbtnBike = rdbtnBike;
	}
	/**
	 * @return the rdbtnProducts
	 */
	public JRadioButton getRdbtnProducts() {
		return rdbtnProducts;
	}
	/**
	 * @param rdbtnProducts the rdbtnProducts to set
	 */
	public void setRdbtnProducts(JRadioButton rdbtnProducts) {
		this.rdbtnProducts = rdbtnProducts;
	}
	/**
	 * @return the rdbtnAmbasssador
	 */
	public JRadioButton getRdbtnAmbasssador() {
		return rdbtnAmbasssador;
	}
	/**
	 * @param rdbtnAmbasssador the rdbtnAmbasssador to set
	 */
	public void setRdbtnAmbasssador(JRadioButton rdbtnAmbasssador) {
		this.rdbtnAmbasssador = rdbtnAmbasssador;
	}
	/**
	 * @return the rdbtnStairway
	 */
	public JRadioButton getRdbtnStairway() {
		return rdbtnStairway;
	}
	/**
	 * @param rdbtnStairway the rdbtnStairway to set
	 */
	public void setRdbtnStairway(JRadioButton rdbtnStairway) {
		this.rdbtnStairway = rdbtnStairway;
	}
	/**
	 * @return the comboBox
	 */
	public JComboBox getComboBox() {
		return comboBox;
	}
	/**
	 * @param comboBox the comboBox to set
	 */
	public void setComboBox(JComboBox comboBox) {
		this.comboBox = comboBox;
	}

	/**
	 * @return the txtNewCategoryName
	 */
	public JTextField getTxtNewCategoryName() {
		return txtNewCategoryName;
	}

	/**
	 * @return the txtCategoryAmount
	 */
	public JTextField getTxtCategoryAmount() {
		return txtCategoryAmount;
	}

	/**
	 * @return the buttonGroup
	 */
	public ButtonGroup getButtonGroup() {
		return buttonGroup;
	}

	/**
	 * @return the rdbtnCustom
	 */
	public JRadioButton getRdbtnCustom() {
		return rdbtnCustom;
	}

	/**
	 * @return the btnSubmitNewCategory
	 */
	public JButton getBtnSubmitNewCategory() {
		return btnSubmitNewCategory;
	}
}